<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>账号登录</title>
    <link rel="stylesheet" href="https://minglie.gitee.io/ming_hyperlink_manage/resource/bootstrap/bootstrap3.3.7.min.css">
    <script src="https://minglie.gitee.io/ming_hyperlink_manage/public/easyui/js/jquery.min.js"></script>
    <script src="https://minglie.gitee.io/mingpage/static/js/M_mock.js"></script> 
    <style type="text/css">
        .login-container {
            width: 400px;
            margin: auto;
        }

        .login-nav {
            width: 400px;
            height: 30px;
            padding: 27px 0 24px;
            text-align: center;
            line-height: 0px;
            font-size: 24px;
            color: #666;
        }
    </style>
</head>

<body>
    <div class="login-container">
        <div class="login-nav">
            <a href="">登录/注册</a>
        </div>
        <!-- input框 -->
      
            <div class="form-group">
                <input type="text" name="username" id="usernameId" class="form-control" placeholder="账号">
            </div>
            <div class="form-group">
                <input type="password" name="password" id="passwordId" class="form-control" placeholder="密码">
            </div>
        
            <div class="form-group">
                <button  class="btn btn-primary btn-block" id="loginBtnId" >登录</button>
                <button  class="btn btn-primary btn-block" id="registerBtnId" >注册</button>
            </div>
       
    </div>
</body>
<script>

loginBtnId.onclick=function(){

    $.ajax({
			type: "post",
			url: `/login`,
			xhrFields: { withCredentials: true },
			contentType: "application/json;charset=utf-8",
			data: JSON.stringify({ username: usernameId.value,password:passwordId.value }),
			success: function (r) {
                    if(r.code==3002){
                       M.setAttribute("username",usernameId.value);
                       location.href="/index.html"
                    }else{
                         alert("账号或密码错误")
                    }
			}
	});


}

registerBtnId.onclick=function(){
    alert("禁止注册")
}




    
</script>


</html>